home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 April / PCWorld_2008-04_cd.bin / komercni software / miton / SystemMechanic7Pro.exe / {app} / smhtml.dll / 1033 / HTML / NAVIGATIONWIDGETPANEL.JS < prev    next >
Text File  |  2008-01-24  |  7KB  |  252 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. //To store all the tools and their child tools
  8. var navArrayTools = new Array();
  9.  
  10. //Tool class
  11. function NavTool(id)
  12. {
  13.   this.ID = id;
  14.   this.Title = "title";
  15.   //To store the child tools
  16.   this.NavChildren = new Array();
  17.   
  18.   this.AddChild = __NavToolAddChild;
  19.   
  20.   //Add child tool
  21.   function __NavToolAddChild(Obj)
  22.   {
  23.     this.NavChildren[this.NavChildren.length] = Obj;
  24.   }
  25. }
  26.  
  27. //Child tool class
  28. function NavToolChild(id)
  29. {
  30.   this.ID = id;
  31.   this.Title = "title";
  32.   this.Details = "Details";
  33. }
  34.  
  35. //This class handle all rendering for Tools
  36. function NavToolPanel(ID)
  37. {
  38.   this.ID = ID;
  39.   this.Render = __NavToolPanelRender;
  40.   this.RenderChildTools = __RenderChildTools;
  41.   this.DrawChildTools = __DrawChildTools
  42.   
  43.   //Render the whole tools section
  44.   function __NavToolPanelRender()
  45.   {
  46.     var content = "";
  47.     if ( window.navArrayTools.length == 0 )
  48.         return "";
  49.         
  50.      content += "    <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
  51.     content += "    <tr>";
  52.     content += "      <td width=\"160\" valign=\"top\" bgcolor=\"#c0c0c0\" style=\"border-left:1px solid #c0c0c0\">";
  53.           
  54.     
  55.     content += "<div id=\"divNavTools\" class=\"individual_tools_navi\">";
  56.     content += "<ul>";
  57.     for( var i=0; i<window.navArrayTools.length; i++ )
  58.     {
  59.       var className = (i == 0 ? "active" : "hand");
  60.       content += "<li id=\"li_" + window.navArrayTools[i].ID + "\" onclick=\"SelectNavChild(" + i +  ",'" + window.navArrayTools[i].ID+ "')\" class=\"" + className + "\">" + window.navArrayTools[i].Title + "</li>"; 
  61.     }
  62.     content += "</ul>";
  63.     content += "</div>";
  64.     
  65.     content += "  </td>";
  66.      content += "      <td rowspan=\"3\" style=\"border-right:1px solid #ccc; border-bottom:1px solid #ccc\">";
  67.           
  68.     
  69.     content += "<div id=\"divChildTools_" + this.ID + "\" class=\"content\">";
  70.     content += this.RenderChildTools(window.navArrayTools[0].NavChildren);
  71.     content += "</div>";
  72.     
  73.     //content += "</div>";//Content
  74.     
  75.     content += "</td></tr><tr>";
  76.      content += "    <td height=\"5\" valign=\"bottom\" bgcolor=\"#c0c0c0\"><img src=\"IT_navi_bl.gif\" width=\"5\" height=\"5\" /></td> ";
  77.     content += "    </tr>";
  78.     content += "  </table>";
  79.     
  80.     content += "<p> </p>";
  81.     return content;
  82.   }
  83.   
  84.   //Render only the child tools, using an array of objects 'NavToolChild'
  85.   function __RenderChildTools(ObjArray)
  86.   {
  87.     if(ObjArray == null)
  88.      return "";
  89.      
  90.      var content = "";
  91.     content += "<table width=\"88%\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" class=\"module_items list\">";
  92.      
  93.     for( var i=0; i<ObjArray.length; i++ )
  94.     {
  95.       var className = (i == 0 ? "toprow" : "");
  96.       
  97.        var a = new ActionButton();
  98.         a.Type = ACTION_BUTTON_CUSTOM;
  99.         a.ID = "a_btn_" + ObjArray[i].ID;
  100.         a.Text = "Start";
  101.         a.Width = "50";
  102.         a.FloatClass = "floatR";
  103.         a.Event = "external.DoOnToolStartButtonClick('" + ObjArray[i].ID + "');";
  104.     
  105.       content += "<tr class=\"" + className + "\">";
  106.       content += "  <td><span class=\"module_item_heading\">" + ObjArray[i].Title  + "</span>";
  107.       content +=  ObjArray[i].Details;
  108.       content += "  </td>";
  109.       content += "  <td class=\"action_buttons_col\">";
  110.       content += a.Render();
  111.       
  112.       //content += "  <a href=\"#\">   <img src=\"PT_bt_start.gif\" onclick=\"external.DoOnToolStartButtonClick('" + ObjArray[i].ID + "');\" onmouseover=\"this.src='PT_bt_start_hover.gif'\" onmouseout=\"this.src='PT_bt_start.gif'\"   /></a>";
  113.       content += "  </td>";
  114.       content += "</tr> ";
  115.     }
  116.     content += "</table>";
  117.    return content;
  118.   }
  119.   
  120.   //Draw only child tools for given index of array navArrayTools
  121.   function __DrawChildTools(index)
  122.   {
  123.    var  html = this.RenderChildTools(window.navArrayTools[index].NavChildren);
  124.    Get("divChildTools_" + this.ID).innerHTML = html;
  125.   }
  126. }
  127.  
  128. //Load items to global array using the XML file
  129. function LoadNav(file)
  130. {
  131.   //empty the array
  132.   navArrayTools = new Array();
  133.   
  134.    var nav = null;
  135.    var xmldoc= null;
  136.    if(window.ActiveXObject) 
  137.    {
  138.    xmldoc= new ActiveXObject("MSXML2.DOMDocument.3.0"); //only in ie, load in ie
  139.    xmldoc.load(file);
  140.    }else
  141.    {
  142.     if (document.implementation &&    document.implementation.createDocument)
  143.         {
  144.          xmldoc= document.implementation.createDocument("","",null);
  145.         xmldoc.load(file);    //xml loaded in Mozilla
  146.          alert(file);
  147.         } 
  148.    }
  149.   
  150.     var Categories = xmldoc.getElementsByTagName("category");
  151.     var noCategoryTags = Categories.length;
  152.     var objNavTool = null;
  153.  
  154.     // loop thorough categories
  155.     for( var i=0; i< noCategoryTags; i++ )
  156.     {
  157.        var categoryName = Categories[i].getAttribute("name");
  158.        var categoryId = Categories[i].getAttribute("id");
  159.        
  160.        //Create a new Tool
  161.        objNavTool = new NavTool(categoryId);
  162.        objNavTool.Title = categoryName;
  163.        
  164.        var tools = Categories[i].getElementsByTagName("tool");
  165.        var noToolTags =  tools.length;
  166.        
  167.         // create child tools
  168.         for( var x=0; x< noToolTags; x++ )
  169.         {
  170.             var id = tools[x].getElementsByTagName("id")[0].firstChild.text;
  171.             
  172.              var childid =  tools[x].childNodes[0].firstChild.nodeValue; //ID
  173.              var childTitle = tools[x].childNodes[2].firstChild.nodeValue; //Caption
  174.              var childDetails = tools[x].childNodes[3].firstChild.nodeValue; //Description
  175.              
  176.              //Create a new child tool
  177.              var objNavChildTool = new NavToolChild(childid);
  178.              objNavChildTool.Title = childTitle;
  179.              objNavChildTool.Details = childDetails;
  180.              
  181.              //Add child tool to tool
  182.              objNavTool.AddChild(objNavChildTool);
  183.         }
  184.        //Add tool to the global array
  185.        navArrayTools[navArrayTools.length] =   objNavTool;
  186.     }
  187. }
  188.  
  189. function SelectNavChild(index, ID)
  190. {
  191.   var q = new NavToolPanel("nav");
  192.   q.DrawChildTools(index);
  193.   
  194.   //Changing the selected tool css class  
  195.   for( var i=0; i<window.navArrayTools.length; i++ )
  196.   {
  197.     var id = "li_" +  window.navArrayTools[i].ID;
  198.    SetClass(id, "hand");
  199.   }
  200.    SetClass("li_" + ID, "active");
  201. }
  202.  
  203.  
  204. function LoadNavigation(file)
  205. {
  206.   //Load items to array using the XML
  207.   LoadNav(file);
  208.   
  209.   //Render the tools
  210.   var q = new NavToolPanel("nav");
  211.   Get('divNavToolsBody').innerHTML = q.Render();
  212.   
  213.   
  214.   scaleDivTools();
  215. }
  216.  
  217.  
  218. function SetLanguage (Language){
  219.    Get("spLOC_IndividualTools").innerHTML=spLOC_IndividualTools;    
  220.     
  221. };
  222.  
  223.  
  224. /// test 
  225. function nav2()
  226. {
  227.   LoadNavigation("NavStandard.xml")
  228. }
  229.  
  230.  
  231.  
  232. function nav1()
  233. {
  234. LoadNavigation("NavStandard.xml");
  235. }
  236.  
  237. function nav2()
  238. {
  239.  //GrayOut(true);
  240.  //scaleDivTools() ;
  241.  GrayOut(true);
  242. }
  243.  
  244. //window.onresize = function() {
  245.  
  246. // // scaleDivTools() ;
  247. //};
  248.  
  249.  
  250.  
  251.  
  252.